<template>
  <div>
    <input v-model="text" />
    <button @click="add">添加</button>
    <p>{{ text }}</p>
    <hr />
    <dddcopy
      v-for="(item, a) in arr"
      :key="a"
      :text="text"
      :a="a"
      :item="item"
      @click1="cl(a)"
    ></dddcopy>
    <span v-show="a != 0">总计：{{ arr.length }}条</span>
  </div>
</template>

<script>
import dddcopy from "./ddd copy.vue";
export default {
  props: {},
  components: { dddcopy },
  data() {
    return {
      text: "",
      arr: [],
      a: 0,
    };
  },
  methods: {
    add() {
      this.a = this.text;
      this.arr.push(this.text);
    },
    cl(a) {
      this.arr.splice(a, 1);
      this.a = this.a - 1;
    },
  },
};
</script>
<style scoped>
</style>
